﻿using System;
using System.Collections.Generic;

namespace GnuPGNotepad
{
    public class GPGKey : IDisposable
    {
        #region constructor
        public GPGKey()
        {
            List<string> Uids = new List<string>();
            List<string> EmailAddresses = new List<string>();
        }
        #endregion // constructor

        #region public declarations
        public bool IsDisposed { get; private set; }
        public string Pub { get; set; }
        public string Sec { get; set; }
        public string Fingerprint { get; set; }
        public string Revoke { get; set; }
        public List<string> UIDs { get; set; }
        public List<string> EmailAddresses { get; set; }
        public string Ssb { get; set; }
        public string Sub { get; set; }
        #endregion // public declarations

        #region private declarations
        private static Settings Config = new Settings();
        #endregion // private declarations

        #region public functions
        /// <summary>
        /// KeyFields enum based on sample data from --list-secret-keys --with-colons
        /// </summary>
        public enum KeyFields
        {
            RecordType = 0,
            Validity = 1,
            KeyLength = 2,
            Algorithm = 3,
            KeyID = 4,
            CreationDate = 5,
            ExpirationDate = 6,
            UserIDHash = 7,
            OwnerTrust = 8,
            UserID = 9,
            SignatureClass = 10,
            KeyCapabilities = 11
        }
        #endregion // public functions

        #region IDisposable Members
        /// <summary>
        /// Dispose of object
        /// </summary>
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        /// <summary>
        /// Dispose of objects in class
        /// </summary>       
        protected virtual void Dispose(bool disposing)
        {
            if (!IsDisposed)
                if (disposing)
                {
                    // dispose of objects
                    Config = null;
                    Pub = null;
                    Sec = null;
                    Fingerprint = null;
                    Revoke = null;
                    UIDs = null;
                    EmailAddresses = null;
                    Ssb = null;
                    Sub = null;

                    // mark disposed
                    IsDisposed = true;
                }
        }

        /// <summary>
        /// Destructor method class
        /// </summary>
        ~GPGKey()
        {
            Dispose(false);
        }
        #endregion // IDisposable Members

    }

}
